import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-03-21
 * Time: 19:17
 */
//求阶乘的和

public class Data {
    //方法一:循环

   /*
   public static int circulation(int n) {
        int result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
        }
        return result;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner((System.in));
        System.out.println("请输入要求阶乘的整数：");
        int n = sc.nextInt();
        System.out.println("该数的阶乘是："+circulation(n));
    }

    */

    //方法二：递归
    public static int recursion(int n) {
        if(n == 1) {
            return 1;
        }else{
               return (n - 1) * n;
        }

    }
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("请输入要求阶乘的整数：" );
       int n = sc.nextInt();
       System.out.println("该数的阶乘为：" + recursion(n));
   }
}

